<?php
header("content-type:text/html;charset=utf-8");
$sername="localhost";
$user="root";
$password="123123";
$dbname="xbs_bbs";
try{
    $conn=new PDO("mysql:host=$sername;dbname=$dbname;charset=utf8",$user,$password);

    $sql="select name,sex,age from stus";
    $b=$conn->query($sql);
    foreach($b as $v){
        echo $v['name'];
        echo $v['sex'];
        echo $v['age'];
    }
}catch (PDOException $e){
    echo $e->getMessage();

}
